//
//  WJHotLable.m
//  WJBSApp
//
//  Created by dllo on 16/7/13.
//  Copyright © 2016年 王景伟. All rights reserved.
//

 /*********************白天为灰色的Lable*******************************/
#import "WJHotLable.h"

@implementation WJHotLable

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"Mode"] isEqualToString:@"night"]) {
            self.backgroundColor = FORBLACKCOLOR;
            self.textColor = [UIColor whiteColor];
        }else{
            self.backgroundColor = LABLECOLOR;
            self.textColor = [UIColor grayColor];
        }
        // 创建观察者
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeColor:) name:@"changeColor" object:nil];
        
        
    }
    return self;
}

- (void)changeColor:(NSNotification *)cation
{
    if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"Mode"] isEqualToString:@"night"]) {
        self.backgroundColor = FORBLACKCOLOR;
        self.textColor = [UIColor whiteColor];
    }else{
        self.backgroundColor = LABLECOLOR;
        self.textColor = [UIColor grayColor];
    }
}

// 销毁观察者
- (void)dealloc{
    [super dealloc];
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

@end
